package com.packagetracker.carriers;

import java.util.LinkedList;

public class PackageActivity {
	
	private LinkedList<PackageLocation> locations;
	
	public PackageActivity() {
		this.locations = new LinkedList<PackageLocation>();
	}
	
	public LinkedList<PackageLocation> getLocations() {
		return this.locations;
	}
	
	public PackageLocation getLocation(final int location) {
		return this.getLocations().get(location);
	}
	
	public PackageLocation getLocation(final String city, final String state) {
		for (final PackageLocation location : this.getLocations()) {
			if (city.equals(location.getCity()) && state.equals(location.getStateProvinceCode())) {
				return(location);
			}
		}
		
		return null;
	}
	
	public void addLocation(final PackageLocation location) {
		this.getLocations().addFirst(location);
	}
	
	public boolean locationExists(final String city, final String state) {
		return (this.getLocation(city, state) != null);
	}
	
	public boolean hasLocations() {
		return (this.getLocations().size() > 0);
	}
	
}